package com.example.myapplication.service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

import androidx.annotation.Nullable;

import com.example.myapplication.IMyService;

public class MyService extends Service {
    private final String TAG = "MyService";
    private final IMyService.Stub binder = new IMyService.Stub() {

        @Override
        public void Log() throws RemoteException {
            Log.d(TAG, "Log: IMyService--->Log()");
        }

        @Override
        public String ShowMsg(String msg) throws RemoteException {
            Log.d(TAG, String.format("Log: MyService Receive msg:%s", msg));
            return String.format("Log: MyService Receive msg:%s", msg);
        }

    };

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.d(TAG, "服务已绑定");
        return binder;
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.d(TAG, "服务已解除绑定");
        return super.onUnbind(intent);
    }
}
